package com.css.common.core.utils;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @description: 金额工具类
 * @Author xlw
 * @Title: AmountUtil
 * @Package com.invoice.tcc.util
 * @Date 2024/8/17 6:14
 */
public class AmountUtil {

    private static final BigDecimal SCALE = new BigDecimal("100");

    public static BigDecimal yuanTofen(BigDecimal yuan) {
        if (Objects.isNull(yuan)) {
            return BigDecimal.ZERO;
        }
        return yuan.multiply(SCALE);
    }

    public static BigDecimal fenToyuan(BigDecimal fen) {
        return fen.divide(SCALE);
    }
}
